package cn.edu.scau.cmi.zhangxiyang.client;

import cn.edu.scau.cmi.zhangxiyang.Factory.InsuranceProduct;
import cn.edu.scau.cmi.zhangxiyang.Factory.SimpleFactory;
import java.util.*;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;  
import javafx.stage.Stage;  
import javafx.scene.layout.*;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;  
import javafx.scene.Scene;  

public class SimpleFactoryClient extends Application{
	
	public void start(Stage primaryStage) {
		
		Stage stage = new Stage();
		BorderPane border = new BorderPane();
		GridPane gp = new GridPane();
		border.setCenter(gp);
		TextArea text = new TextArea();
		border.setBottom(text);
		
		gp.setHgap(10);
		gp.setVgap(10);
		gp.setPadding(new Insets(0, 10, 0, 10));
		
		ImageView face = new ImageView(new Image("http://a3.qpic.cn/psb?/V14a9IL505Awnp/SBSTRB341YS9JLMiYy6v8HV*rA2VMPliRbhvfBEh0ng!/b/dLYAAAAAAAAA&ek=1&kp=1&pt=0&bo=QAZVCMAP0AsRGSE!&tl=3&vuin=1252032729&tm=1558850400&sce=60-1-1&rf=viewer_4"));
		face.setFitHeight(100);
		face.setFitWidth(100);
		gp.add(face, 1, 2);
		
		Label label1 = new Label("姓名：");
		gp.add(label1, 1, 0);
		
		Label label2 = new Label("the chainsmoker");
		gp.add(label2, 2, 0);
		
		Label label3 = new Label("学号：");
		gp.add(label3, 3, 0);
		
		Label label4 = new Label("201627010428");
		gp.add(label4, 4, 0);
		
		Label label5 = new Label("请选择产品：");
		gp.add(label5, 1, 1);
		
		ComboBox combobox = new ComboBox();
		combobox.getItems().addAll("BodyInjury","CarDamage","Casualties","MultipleAccidents");
		gp.add(combobox, 2, 1);
		
		Button btn = new Button("显示产品信息");
		gp.add(btn, 3, 1);
		
		btn.setOnAction(e -> {  
			if(combobox.getValue() != null) {
				InsuranceProduct product = SimpleFactory.useProduct(combobox.getValue().toString());
				text.setText(product.use());
			}
        });
		
	
		
		stage.setScene(new Scene(border,500,500));
		stage.setTitle("ʵ����򵥹�������");
        stage.show();
	}
	

	public static void main(String args[]) {
		launch(args);
	}

}
